<?php
class Adm_Form_Element_City extends
	Zend_Form_Element_Select
{ 	
   public function __construct( $name, $cities, $allowEmpty = false)
   {
		parent::__construct($name);  	

		$options = array();
		
		foreach ($cities as $city){
			
			$letra = substr($city->__toString(), 0, 1);
			
			$options[$letra][$city->getId()] = $city->__toString();
		}
		
		ksort( $options );
		
		foreach($options as &$option){
			asort($option);
		}
		
		$ids = $cities->getIds();
		
		if ($allowEmpty){
		    $options = array_merge(array( 0 => ''), $options);
		    $ids[]=0;
		} 
		
		$this->addMultiOptions( $options );
		$this->addValidator( new Zend_Validate_InArray( $ids) );
   }
	
}	
	
	